/*
 * searchTableModel.java
 *
 * Created on June 27, 2005, 3:36 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */
package com.bff.slimserver.musicjukebox.lib;

import com.bff.bjj.utils.Resources.LABEL_KEY;
import org.bff.slimserver.exception.SlimConnectionException;
import org.bff.slimserver.exception.SlimDatabaseException;
import org.bff.slimserver.musicobjects.SlimAlbum;
import org.bff.slimserver.musicobjects.SlimSong;

/**
 *
 * @author Bill
 */
public class VariousArtistAlbumTableModel extends SongTableModel {

    public static final int ARTIST = 0;
    public static final int TITLE = 1;
    public static final int LENGTH = 2;
    public static final int TRACK = 3;
    public static final int YEAR = 4;
    public final static String[] columnNames = {
        getHeader(LABEL_KEY.HEADER_ARTIST),
        getHeader(LABEL_KEY.HEADER_TITLE),
        getHeader(LABEL_KEY.HEADER_LENGTH),
        getHeader(LABEL_KEY.HEADER_TRACK),
        getHeader(LABEL_KEY.HEADER_YEAR)
    };

    public VariousArtistAlbumTableModel(SlimAlbum album) throws SlimConnectionException, SlimDatabaseException {
        super(JukeboxProperties.getInstance().getDatabase().listSongsForAlbum(album));
    }

    @Override
    public int getRowCount() {
        return (dataList.size());
    }

    @Override
    public Object getValueAt(int row, int col) {
        SlimSong song = (SlimSong) dataList.get(row);
        switch (col) {
            case ARTIST:
                return (song.getArtist());
            case TITLE:
                return (song.getTitle());
            case LENGTH:
                return (song.getLength());
            case TRACK:
                return (song.getTrack());
            case YEAR:
                return (song.getYear());
            default:
                return null;
        }
    }

    @Override
    public int getColumnCount() {
        return (columnNames.length);
    }

    @Override
    public String getColumnName(int column) {
        return columnNames[column];
    }

    @Override
    public int getArtistColumnIndex() {
        return (ARTIST);
    }

    @Override
    public int getTitleColumnIndex() {
        return (TITLE);
    }

    @Override
    public int getLengthColumnIndex() {
        return (LENGTH);
    }

    @Override
    public int getTrackColumnIndex() {
        return (TRACK);
    }

    @Override
    public int getYearColumnIndex() {
        return (YEAR);
    }

    @Override
    public int getBitrateColumnIndex() {
        return (-1);
    }

    @Override
    public int getSortColumn() {
        return getTitleColumnIndex();
    }

    @Override
    public int getAlbumColumnIndex() {
        return -1;
    }
}
